/* Yet Another Experimental Software Renderer
 *
 * Copyright (c) 2010 Pawel "Hery" Dziepak
 */

#include "interpolate.h"
#include "utils.h"

using namespace yaesr;

vertex interpolate::interpolate_line(vertex a, vertex b, double mix) {
	vertex vert;

	vert.position = lerp(a.position, b.position, mix);
	vert.color0 = lerp(a.color0, b.color0, mix);
	vert.texcoord0 = lerp(a.texcoord0, b.texcoord0, mix);

	return vert;
}

vertex interpolate::interpolate_triangle(vertex a, vertex b, vertex c, double alpha, double beta, double gamma) {
	vertex vert;

	vert.position = lerp3(a.position, alpha, b.position, beta, c.position, gamma);
	vert.color0 = lerp3(a.color0, alpha, b.color0, beta, c.color0, gamma);
	vert.texcoord0 = lerp3(a.texcoord0, alpha, b.texcoord0, beta, c.texcoord0, gamma);

	return vert;
}
